<%--
  Created by IntelliJ IDEA.
  User: lsh
  Date: 2020/8/30
  Time: 10:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-3.5.1.js"></script>
</head>
<body>
<form action="/Login_demo/add" >
    学号：<input  id="id" type="text"  name="id" ><span id="msg"></span><br>
    用户名 ：<input id="username" type="text"  name="username" ><br>
    性别 ：<input type="radio" name="hobby" value="男"  /> 男
    <input type="radio" name="hobby" value="女"/> 女 <br>
    生日：<input type="text" name="bir" id="bir"><br>
    <input type="submit" value="登入"><br>
    <input type="button"  value="ajax发送表单" onclick="send()">


</form>
<input type="button" value="添加用户"><br>
</body>
<script>
    function send() {
        alert("这里是ajax提交表单")
        var student = {"id":$("#id").val(),
                        "username":$("#username").val(),
                        "sex":$(":radio:checked").val(),
                        "bir":$("#bir").val()
        };
        $.ajax({
            url:"/Login_demo/addAjax"
            ,
            async:false,
            data:student
            ,
            type:"GET"
            ,
            dataType:"json"
            ,
            success:function(data){
                alert(data);
            },
            error:function(){
                alert("数据没有成功返回!")
            }
        });

    }
</script>
</html>
